<?php
session_start();

if(isset($_SESSION['emaild']))
{
	$userid=$_SESSION['emaild'];
	$ar=split("@",$userid);
	$user=$ar[0];
}
else
{
	
	$user="Anonymous";
}
	require 'dbconnect.inc.php';

	//this inserts annotations into database
	$annotation=$_GET['annotation'];
	$text=$_GET['text'];
	$start=$_GET['startpos'];
	$end=$_GET['endpos'];
	$datestamp=date('Y-m-d');
	

	$mysql_table="content";

	$query="insert into $mysql_table (text,annotation,date,spos,epos,user)	
	values('$text','$annotation','$datestamp','$start','$end','$user')";

	if($text!='null' && $annotation!='null' && $text!="" && $annotation!=""){	
		$queryresult=mysqli_query($link,$query) or die($conn_error_msg);
	}

	mysqli_close($link);

	echo '<script type="text/javascript">
			window.location.href = "retrieve_annotations.inc.php?text="+'.$start.';
			</script>';

	//include 'retrieve_annotations.inc.php?text=$start';
	//echo 'success!';
	//header('Location: main.php');
	mysqli_close($link);



?>
